/**
*  \file cryptutil.h
*
*  \brief Cryptographic hash function utility
*
*  This module contains common constant data, definitions, macros and functions that are used in for the MD5 and SHA2 algorithms.
*
*  \author D'Aprea F.  <francesco.daprea@linde-mh.de>
*
*
*/

#ifndef CRYPTUTIL_H_INCLUDED
#define CRYPTUTIL_H_INCLUDED

/*================================================[ public includes  ]================================================*/
#include "../cfg/prj.h"
#include "../binarith/binarith.h"

/*================================================[ public defines   ]================================================*/

#define CRY_NO_OF_MSG_PADDING_BYTES 64U /**< Number of padding bytes that are needed to fill up a message packet. */

/*================================================[ public datatypes ]================================================*/

/*================================================[ public variables ]================================================*/
/**
*  This constant array contains the the padding data that are needed to fill up a complete message packet.
*  Padding a message packet has always to be done to finalize the calculation of MD5 and SHA2 checksum.
*/
extern const U8 CRY_MSG_PADDING[CRY_NO_OF_MSG_PADDING_BYTES];

/*================================================[ public functions ]================================================*/

/**
*  This fnction converts the endian of 16 32-bit values from litte to big endian or big to little endian.
*
*  \param arg_ptr_packet Pointer to 16 32-bit values.
*/             
STATIC_INLINE void cry_conv_endian_packet( U32 * const arg_ptr_packet)
{
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[ 0U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[ 1U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[ 2U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[ 3U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[ 4U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[ 5U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[ 6U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[ 7U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[ 8U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[ 9U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[10U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[11U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[12U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[13U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[14U]);
   BIN_CONV_ENDIAN_U32(arg_ptr_packet[15U]);
}

#endif

/***********************************************************************************************************************
*                             Copyright 2011 Linde Material Handling. All rights reserved.                             *
***********************************************************************************************************************/

